Namespace Web.page

    Public Class reactivate
        Inherits [lib].BasePage
        Protected WithEvents ddl_rp As System.Web.UI.WebControls.DropDownList
        Protected WithEvents ddl_reason As System.Web.UI.WebControls.DropDownList
        Protected WithEvents proc As System.Web.UI.HtmlControls.HtmlInputHidden
        Protected WithEvents txt_msisdn As System.Web.UI.WebControls.TextBox
        Protected WithEvents Lblok As System.Web.UI.WebControls.Label
        Protected WithEvents dg_DATA As System.Web.UI.WebControls.DataGrid

#Region " Web Form Designer Generated Code "

        'This call is required by the Web Form Designer.
        <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()

        End Sub

        Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
            'CODEGEN: This method call is required by the Web Form Designer
            'Do not modify it using the code editor.
            InitializeComponent()
        End Sub

#End Region

        Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            'Put user code to initialize the page here
            Dim SQL As String
            Dim SQL1 As String
            Dim usr As String
            Dim ds As New myDBConn
            Session.LCID = 1055

            Me.PageTitle = "Reactivation"
            If Page.IsPostBack Then Exit Sub

            SQL = " select rs_id,rs_desc from  reasonstatus_all"
            SQL = SQL & " where rs_status='a'"
            SQL = SQL & " and rs_id in (17,18,19)"
            Me.ddl_reason.DataSource = ds.myORATable(SQL)
            Me.ddl_reason.DataTextField = "rs_desc"
            Me.ddl_reason.DataValueField = "rs_id"
            Me.ddl_reason.DataBind()

            SQL1 = " select tmcode,des from  mputmtab where vscode=0"
            SQL1 = SQL1 & " and des not like 'NOT USED%'"
            SQL1 = SQL1 & " and tmcode in (select tmcode from mpulknxg "
            SQL1 = SQL1 & " where prgcode in ('01','13','14','15','16','17','18','19','20','21','22','23') )"
            SQL1 = SQL1 & " and tmcode not in (32,33,34,35,36,37,11,17,18,19,22,26,51,309,52) order by des"
            Me.ddl_rp.DataSource = ds.myORATable(SQL1)
            Me.ddl_rp.DataTextField = "des"
            Me.ddl_rp.DataValueField = "tmcode"
            Me.ddl_rp.DataBind()
            ds = Nothing

        End Sub



        Private Sub btncreate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
            Dim usr As String
            Dim sql As String
            Dim sql2 As String
            Dim ds As New myDBConn
            Dim avail_date As String
            Dim v_reason As Integer

            If Me.txt_msisdn.Text = "" Or Me.txt_msisdn.Text = "" Then
                Message += "alert(' Please fill the required fields!!');"
                'Response.Write("<SCRIPT language=""JavaScript"">" & vbCrLf & "{" & vbCrLf)
                'Response.Write("alert("" Please fill the required fields!!"")" & vbCrLf)
                'Response.Write("}" & vbCrLf & "</SCRIPT>" & vbCrLf)
                ' Me.btncreate.Enabled = False
                Exit Sub
            End If

            sql2 = "SELECT DN_NUM FROM eu_bill.view_directory_number WHERE DN_NUM='" & Me.txt_msisdn.Text & "'"

            If ds.myORATable(sql2).Rows.Count = 0 Then
                Message += "alert(' MSISDN  NOT FOUND!!');"
                'Response.Write("<SCRIPT language=""JavaScript"">" & vbCrLf & "{" & vbCrLf)
                'Response.Write("alert("" MSISDN  NOT FOUND!!"")" & vbCrLf)
                'Response.Write("}" & vbCrLf & "</SCRIPT>" & vbCrLf)
                ' Me.btncreate.Enabled = False
                Exit Sub
            End If

            sql2 = "SELECT DN_NUM FROM eu_bill.view_directory_number WHERE DN_NUM='" & Me.txt_msisdn.Text & "' AND DN_STATUS  <>'r'"

            If ds.myORATable(sql2).Rows.Count > 0 Then
                Message += "alert(' MSISDN IS NOT AVAILABLE,CHECK RESOURCE STATUS!!');"
                'Response.Write("<SCRIPT language=""JavaScript"">" & vbCrLf & "{" & vbCrLf)
                'Response.Write("alert("" MSISDN IS NOT AVAILABLE,CHECK RESOURCE STATUS!!"")" & vbCrLf)
                'Response.Write("}" & vbCrLf & "</SCRIPT>" & vbCrLf)
                ' Me.btncreate.Enabled = False
                Exit Sub
            End If

            'v_reason = 18
            v_reason = Me.ddl_reason.SelectedItem.Value
            avail_date = Format(Now.AddHours(1), "dd.MM.yyyy HH:00:00")
            usr = Request.ServerVariables("LOGON_USER")
            sql = "insert into it_reactivation (entry_id,msisdn,tmcode,reason,entry_date,entry_user,status)"
            sql = sql & " values((select max(entry_id)+1 from it_reactivation),'" & Me.txt_msisdn.Text & "','" & Me.ddl_rp.SelectedItem.Value & "','" & v_reason & "',sysdate,'" & usr & "',0) "
            ds.ORAExecute(sql)
            Message += "document.getElementById('Button_2').disabled = false;"
            'Me.btncreate.Enabled = True

            Dim prInfo As New System.Diagnostics.ProcessStartInfo
            prInfo.RedirectStandardOutput = True
            prInfo.FileName = "rsh"
            prInfo.UseShellExecute = False
            prInfo.Arguments = "10.4.14.21 -l bscsadm  ""/bscs/bscsadm/usr/bin/IT_REACTIVATION/SHL/Reactivate.sh '" & Me.txt_msisdn.Text & "'"""
            Dim procFTP As New System.Diagnostics.Process

            procFTP.StartInfo = prInfo
            procFTP.Start()

            Dim strOutput As String = procFTP.StandardOutput.ReadToEnd

            procFTP.WaitForExit()

            sql2 = "select status,creation_details,iccid from it_reactivation where entry_id=(select max(entry_id) from it_reactivation where msisdn ='" & Me.txt_msisdn.Text & "')"
            If ds.myORATable(sql2).Rows(0)(0) = 2 Then
                Me.Lblok.Text = "CUSTOMER REACTIVATED.."
                Me.Lblok.Visible = True
                sql = "SELECT MSISDN,ICCID,CUSTOMER_ID,CO_ID FROM IT_REACTIVATION WHERE MSISDN='" & Me.txt_msisdn.Text & "' and status=2 and entry_id=(select max(entry_id) from it_reactivation where msisdn ='" & Me.txt_msisdn.Text & "')"
                Me.dg_DATA.DataSource = ds.myORATable(sql)
                Me.dg_DATA.DataBind()
                Me.dg_DATA.Visible = True
            Else
                Me.Lblok.Text = "ERROR IN CUSTOMER REACTIVATION!! " & ds.myORATable(sql2).Rows(0)(1) & "  " & ds.myORATable(sql2).Rows(0)(2)
                Me.Lblok.Visible = True
                Me.dg_DATA.Visible = False

            End If

        End Sub

        Private Sub Btncancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
            Me.txt_msisdn.Text = ""
            Me.dg_DATA.Visible = False
            Me.Lblok.Visible = False

        End Sub
    End Class

End Namespace
